import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import { getToken } from "../utils/auth";
import vuex from "../store/index";
import { addRouter } from "./addRouter";
import { message } from "ant-design-vue";
// 路由信息
const routess: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Index",
    component: () => import("../page/index.vue"),
    children: [
      {
        path: "/",
        name: "Dashboard",
        component: () => import("../page/dashboard/dashboard.vue"),
        meta: {
          title: "控制台",
        },
      },
      {
        path: "/error/401",
        name: "Error401",
        component: () => import("../page/errorpage/401.vue"),
        meta: {
          title: "错误401",
        },
      },
      {
        path: "/error/403",
        name: "Error403",
        component: () => import("../page/errorpage/403.vue"),
        meta: {
          title: "错误403",
        },
      },
      {
        path: "/error/404",
        name: "Error404",
        component: () => import("../page/errorpage/404.vue"),
        meta: {
          title: "错误404",
        },
      },
      {
        path: "/project/list",
        name: "projectList",
        component: () => import("../page/project/projectlist.vue"),
        meta: {
          title: "项目列表",
        },
      },
      {
        path: "/project/:id",
        name: "projectID",
        component: () => import("../page/project/projectid.vue"),
        meta: {
          title: "项目详情",
        },
      },
    ],
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../page/login/login.vue"),
    meta: {
      title: "管理员登录",
    },
  },
];

// 白名单
export const routes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "login",
    component: () => import("../page/login/login.vue"),
    meta: {
      title: "管理员登录",
    },
  },
  {
    path: "/err/404",
    name: "error404",
    component: () => import("../page/errorpage/404.vue"),
    meta: {
      title: "错误404",
    },
  },
];

const whiteList = ["/login"];
// 导出路由
const router = createRouter({
  history: createWebHistory(),
  routes,
});
export default router;
